package com.qyc.exception;

import com.qyc.enums.CodeMsgEnum;

/**
 * @className: SystemException
 * @Description: 自定义异常
 * @author: qinyc
 * @date: 2023/6/20 21:57
 * @version: v1.0
 */

public class SystemException extends RuntimeException{
    /*
     * 状态码
     */
    private int code;

    /*
     * 提示信息
     */
    private String msg;

    /*
     * 获取状态码
     */
    public int getCode() {
        return code;
    }

    /*
     * 获取提示信息
     */
    public String getMsg() {
        return msg;
    }

    /*
     * 构造器，将枚举状态码和提示信息作为参数传入
     */
    public SystemException(CodeMsgEnum codeMsgEnum) {
        super(codeMsgEnum.getMsg());
        this.code = codeMsgEnum.getCode();
        this.msg = codeMsgEnum.getMsg();
    }

    /*
     * 构造器 ，将状态码和提示信息作为参数传入
     */
    public SystemException(int code,String msg){
        this.code = code;
        this.msg = msg;
    }
}
